import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class ChatClient {
    public static void main(String[] args) {
        try {
            Socket client = new Socket("107-19",9900);
            System.out.println("请输入姓名：");
            Scanner scanner = new Scanner(System.in);
            String name = scanner.nextLine();
            OutputStream os =client.getOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(os);
            oos.writeObject(name);
            InputStream is = client.getInputStream();
            ObjectInputStream ois = new ObjectInputStream(is);
            String msg = (String) ois.readObject();
            System.out.println(msg);

        } catch (IOException e) {
            throw new RuntimeException(e);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
}
